 <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>全选/反选/多选</title>
    <link rel="stylesheet" href="./css/style.css"/>
  </head>
  <body>
    <div id="app">
      <div class="row">
        <div class="relatedInstance">
          <ul>
            <li id="">
              <div class="tabItem">
                <input type="checkbox" v-model="allCheck"/>
                <span @click="showFn"> 人员 </span>
              </div>

              <ul v-show="isShow">
                <li v-for="(item,index) in entities[0].child">
                  <input type="checkbox" v-model="item.isCheck" />
                  <span>{{item.text}}</span>
                </li>
              </ul>
            </li>
            <li id="">
              <div class="tabItem">
                <input type="checkbox"  v-model="allCheck1"/>
                <span @click="isShow1 = !isShow1"> 项目 </span>
              </div>

              <ul  v-show="isShow1">
                <li v-for="(item,index) in entities[1].child">
                  <input type="checkbox" v-model="item.isCheck"/>
                  <span>{{item.text}}</span>
                </li>
               
              </ul>
            </li>
            <li id="">
              <div class="tabItem">
                <input type="checkbox"  v-model="allCheck2"/>
                <span @click="isShow2 = !isShow2"> 机构 </span>
              </div>

              <ul  v-show="isShow2">
                <li v-for="(item,index) in entities[2].child">
                  <input type="checkbox" v-model="item.isCheck"/>
                  <span>{{item.text}}</span>
                </li>
              </ul>
            </li>
          </ul>
        </div>
      </div>
    </div>

    <script src="./js/vue.js"></script>
    <script>
      var newlist = new Vue({
        el: "#app",
        data: {
         
          isShow:false,
          isShow1:false,
          isShow2:false,
          entities: [
            {
              text: "人员",
              child: [
                { text: "第一组01",isCheck:false },
                { text: "第一组02" ,isCheck:false},
                { text: "第一组03" ,isCheck:false},
                { text: "第一组04" ,isCheck:false},
                { text: "第一组05" ,isCheck:false},
              ],
            },
            {
              text: "项目",
              child: [{ text: "第二组01",isCheck:false }, { text: "第二组02" ,isCheck:false}],
            },
            {
              text: "机构",
              child: [
                { text: "第三组01",isCheck:false },
                { text: "第三组02" ,isCheck:false},
                { text: "第三组03",isCheck:false },
                { text: "第三组04",isCheck:false },
              ],
            },
          ],
        },
        methods: {
          showFn(){
            this.isShow = !this.isShow;
            if(this.isShow == true){
              this.isShow1 = false
              this.isShow2 = false
            }
          }
        },
        computed: {
          allCheck:{
           
            get(){
              return this.entities[0].child.every((item) => {
                return item.isCheck == true
              })
            },
           
            s et(v){
              this.entities[0].child.forEach((item) => {
                item.isCheck = v
              })
            }
          },
          allCheck1:{
            get(){
              return this.entities[1].child.every((item) => {
                return item.isCheck == true
              })
            },
            set(v){
              this.entities[1].child.forEach((item) => {
                item.isCheck = v
              })
            }
          },
          allCheck2:{
            get(){
              return this.entities[2].child.every((item) => {
                return item.isCheck == true
              })
            },
            set(v){
              this.entities[2].child.forEach((item) => {
                item.isCheck = v
              })
            }
          }
        },
      
      });
    </script>
  </body>
</html>